import { NodeStatus } from "../Enum";
import BTNode from "./BTNode";

export default abstract class BTParent extends BTNode
{
    childens: Array<BTNode> = [];
    root: BTNode;
    private _index = 0;
    get index()
    {
        return this._index;
    }

    set index(index: number)
    {
        this._index = index;
    }

    constructor(childens: Array<BTNode>)
    {
        super(); 
        this.childens = childens;
    }

    abstract canExecute(): boolean;

    abstract onChildExecuted(childStatus: NodeStatus): void;

    declare(status: NodeStatus)
    {
        return status;
    }

    onConditionalAbort(index: number)
    {
        this.index = index;
        this.status = NodeStatus.Inactive;
    }
}